package secure

import (
	"crypto/sha1"
	"crypto/sha256"
	"crypto/sha512"
	"encoding/hex"
	"fmt"
)

func Sha256Hex(data []byte) string {
	sum := sha256.Sum256(data)
	return fmt.Sprintf("%x", sum)
}

func Sha256Hex_file(data []byte) string {
	return hex.EncodeToString(Sha256_file(data))
}

func Sha256_file(data []byte) []byte {
	digest := sha256.New()
	digest.Write(data)
	return digest.Sum(nil)
}

func Sha1Hex(data []byte) string {
	sum := sha1.Sum(data)
	return fmt.Sprintf("%x", sum)
}

func Sha512Hex(data []byte) string {
	sum := sha512.Sum512(data)
	return fmt.Sprintf("%x", sum)
}
